<?php
/**
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/4/1
 * Time: 13:16
 *
 */
class ShowteachhealthylistController extends Yaf_Controller_Abstract
{
    public function IndexAction()
    {
        $request = $this->getRequest();
        $user_department = $request->getPost("user_department","");
        $yiyuan_id = $request->getPost("yiyuan_id","");
        if($yiyuan_id === "" )
        {
            Utility::apiJsonError(20028, '请输入医院ID');
        }
        elseif(!ctype_digit("$yiyuan_id")) {
            Utility::apiJsonError(20027, '医院ID必须是整型');
        }
        if(empty($user_department))
        {
            Utility::apiJsonError(20060, '科室不能为空!');
        }
        $res = DB::select("id,healthy_title,healthy_context,user_number,user_department,user_info,add_time")
            ->from("hospital_teach_healthy")
            ->where("yiyuan_id","=",$yiyuan_id)
            ->and_where("user_department","=",$user_department)
            ->execute()
            ->as_array();
        $data['error'] = 200;
        $data['msg'] = "";
        $data['data'] = $res;
        if($res){
            $data['state'] = 1;
        }else{
            $data['state'] = 0;
        }
        Utility::apiJsonResultExtends($data);
    }
}